﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace HCM_maps_website.Process.BLL
{
    public class XMLHelper
    {
        static XmlElement root;
        public static void LoadFile(string path)
        {
            XmlDocument doc = new XmlDocument();
            try
            {
                doc.Load(path);
            }
            catch
            {
                root = null;
            }

            root = doc.DocumentElement;
        }

        public static List<string> GetListAbbr()
        {
            List<string> result = new List<string>();
            XmlNodeList lst = root.SelectNodes("//pat");
            foreach (XmlNode node in lst)
                result.Add(node.InnerText);
            return result;
        }

        public static List<string> GetListPat(string word)
        {
            List<string> result = new List<string>();
            XmlNodeList lst = root.SelectNodes("//expansion[pat='" + word + "']/pat");
            foreach (XmlNode node in lst)
                result.Add(node.InnerText);
            return result;
        }


    }
}
